﻿using DAL.Permission.Manage;
using Model.Permission;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL.Permission.Manage
{
    public class SupplierUserBLL
    {
        SupplierUserDAL dal = new SupplierUserDAL();

          /// <summary>
        /// 更新登录时间和ip
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public bool UpdateIPAndLoginTime(int uid, string LastLoginIP, string LastLoginTime)
        {
            return dal.UpdateIPAndLoginTime(uid, LastLoginIP, LastLoginTime);
        }

        /// <summary>
        /// 得到一个对象实体
        /// <param name="loginname">登录名</param>
        /// <param name="password">密码 注意该字段为解密后</param>
        /// </summary>
        public SupplierUserEntity GetModel(string loginname, string password)
        {
            return dal.GetModel(loginname, password);
        }

        /// <summary>
        /// 更新某用户的密码
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public bool UpdatePwd(int uid, string pwd)
        {
            return dal.UpdatePwd(uid, pwd);
        }

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <returns></returns>
        public bool DisableUser(int uid)
        {
            return dal.DisableUser(uid);
        }

        /// <summary>
        /// 是否存在该记录
        /// <param name="LoginName">登录名</param>
        /// <param name="Password">密码</param>
        /// </summary>
        public int? Exists(string LoginName, string Password)
        {
            return dal.Exists(LoginName, Password);
        }

        /// <summary>
        /// 用户名是否存在
        /// </summary>
        /// <param name="LoginName">登录名</param>
        /// <returns></returns>
        public bool ExistsName(string LoginName)
        {
            return dal.ExistsName(LoginName);
        }

        /// <summary>
        /// 是否存在当前用户名以外的其他用户名
        /// </summary>
        /// <param name="LoginName">登录名</param>
        /// <param name="UserID">密码</param>
        /// <returns></returns>
        public bool ExistsOtherUser(string LoginName, int UserID)
        {
            return dal.ExistsOtherUser(LoginName, UserID);
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int UserID)
        {
            return dal.Exists(UserID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SupplierUserEntity model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SupplierUserEntity model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int UserID)
        {

            return dal.Delete(UserID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string UserIDlist)
        {
            return dal.DeleteList(UserIDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SupplierUserEntity GetModel(int UserID)
        {

            return dal.GetModel(UserID);
        }
    }
}
